The present invention relates to an optical information-reading apparatus such as a code scanner, an optical character reader (OCR), or the like, and an optical information-reading method.
A bar code has been used previously for merchandise control, stock management, or the like. As a code symbol that has more increased information density than this bar code, there have been two-dimensional codes such as Data Matrix, QR code, PDF417, Maxi Code, and the like. An apparatus for reading these two-dimensional codes captures the two-dimensional codes with a solid-state image sensing device such as a CMOS image sensor, a CCD image sensor, or the like, and performs various kinds of processing on such a captured two-dimensional code to binarize and decode it.
In the optical character reader (hereinafter referred to as OCR), a principle to read the character is also the same as a principle to read the code. A camera included in a recent portable phone has a built-in code scanner and an OCR so that the code scanner and the OCR use have been widespread. In such a code scanner or such an OCR performances is fixed based on a binarizing function which the code scanner or the OCR has.
In patent document 1 (see below), an image processing apparatus is disclosed which performs binarization processing using an error diffusion method. According to this image processing apparatus, an image read by a scanner is partitioned into blocks. The binarization processing is performed by setting a weighting coefficient, taking contrast between the adjacent blocks into consideration, and setting a threshold value calculated from maximum and minimum values based on the set weighting coefficient.
In patent document 2 (see below), an optical information-reading apparatus that performs binarization processing by run-length processing is disclosed. According to this optical information-reading apparatus, an image read by a scanner is partitioned into lines. For example, a data conversion is performed on the line data so that it is “one pixel of black, two pixels of white, five pixels of black, three pixels of white and five pixels of black”. The binarization processing is performed by setting a threshold value calculated from maximum and minimum values based on the line data thus derived.
In patent document 3 (see below), a binarization method is disclosed in which, between two black peaks (minimum values) adjacent to a white peak (maximum value), a value of this white peak is set to a direct current level; between two white peaks adjacent to a black peak, a value of this black peak is set to a direct current level; and a value between two direct current levels thus obtained is set to a threshold level. According to this binarization method, since the threshold level is set at the value between black and white peaks which is the nearest in an analog image signal to be binarized, a correct binarized signal is obtained even if a portion of low frequency component contained in the analog image signal is large or a frequency of the necessary signal is low.
In patent document 4 (see below), an apparatus for excising a specified serial number from a number plate is disclosed in which a threshold value is set from the largest minimum value among plural minimum values and the smallest maximum value among plural maximum values, the values being detected by a detection means According to this apparatus for excising a specified serial number, a stable binarized image can be obtained regardless of the area of the number plate in the image.
FIG. 15 is a diagram for illustrating a conventional calculation example of a threshold value. As shown in FIG. 15, the horizontal axis is a coordinate x and the vertical axis is the brightness value of a read image Further, the brightness value shown in FIG. 15 is considered to be contained in one block. The conventional calculation method of a threshold value is calculated by obtaining the maximum and minimum values in one block. For example, in FIG. 15, a brightness value corresponding to a point c is the maximum value Amax, and a brightness value corresponding to a point d is the minimum value Amin. A threshold value Ath is the mean value of the maximum value Amax and the minimum value Amin, which is calculated as Ath=(Amax+Amin)/2.
For example, if the brightness value is larger than the threshold value Ath, the binarized signal is estimated as one (white) but if the brightness value is smaller than the threshold value Ath, the binarized signal is estimated as zero (black). Thus, since the brightness value corresponding to the point “a” is a larger value than the threshold value Ath, it is estimated as one (white); since the brightness value corresponding to the point “b” is a larger value than the threshold value Ath, it is estimated as one (white); since the brightness value corresponding to the point “c” is a larger value than the threshold value Ath, it is estimated as one (white); and since the brightness value corresponding to the point “d” is a smaller value than the threshold value Ath, it is estimated as zero (black). However, a binarized signal of the brightness value corresponding to the point “b” should essentially be recognized as zero (black) but when calculating the threshold value using such a method, it is recognized as one (white) by mistake.